package cn.mw.cmdb.entity;

import cn.mw.cmdb.service.ServiceChoose;
import cn.mw.cmdb.service.impl.TableSearchConditionServiceImpl;
import cn.mw.components.mongodb.anno.AutoId;
import cn.mw.components.mongodb.anno.CMDBProperty;
import cn.mw.components.mongodb.entity.SubCondition;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.Map;

@Data
@Document("mw_cmdbmd_table_search")
public class TableSearchConditionDto implements ServiceChoose {

    @CMDBProperty(searchType = PropertyTypeString.ID, searchPrefix = "_")
    @AutoId
    @Schema(description = "id")
    private String id;

    @CMDBProperty(searchType = PropertyTypeString.ID)
    @Schema(description = "查询名称")
    private String name;

    @CMDBProperty(searchType = PropertyTypeString.ID)
    @Schema(description = "创建人")
    private Long creator;

    @CMDBProperty(searchType = PropertyTypeString.ID)
    @Schema(description = "表格id")
    private String tableId;

    @CMDBProperty(searchType = PropertyTypeString.ID)
    @Schema(description = "菜单id")
    private String menuId;

    @CMDBProperty(searchType = PropertyTypeString.ID)
    @Schema(description = "模型或分组id")
    private String modelOrGroupId;

    @CMDBProperty(searchType = PropertyTypeString.ID)
    @Schema(description = "查询条件,字段名 + 条件" ,example = "\"test\": {\"operation\":\"is\" ,\"value\": \"1\"} ")
    private Map<String, SubCondition> condition;

    @Override
    public String getServiceId() {
        return TableSearchConditionServiceImpl.ID;
    }
}
